package com.lzh.media.controller;


import com.lzh.common.pojo.Result;
import com.lzh.common.utils.RequestContextUtil;
import com.lzh.media.entity.WmMaterial;
import com.lzh.media.mapper.WmMaterialMapper;
import com.lzh.media.service.WmMaterialService;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.lzh.core.controller.AbstractCoreController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
* <p>
* 自媒体图文素材信息表 控制器</p>
* @author lzh
* @since 2021-06-24
*/
@RestController
@RequestMapping("/wmMaterial")
public class WmMaterialController extends AbstractCoreController<WmMaterial> {

    @Resource
    private WmMaterialMapper wmMaterialMapper;

    private WmMaterialService wmMaterialService;

    //注入
    @Autowired
    public WmMaterialController(WmMaterialService wmMaterialService) {
        super(wmMaterialService);
        this.wmMaterialService = wmMaterialService;
    }

    @PostMapping("/insert")
    public Result insert(@RequestParam(value = "url") String url) {
        Object user_id = RequestContextUtil.getToken("token", "id");
        WmMaterial material = new WmMaterial();
        material.setUserId(Integer.valueOf(user_id.toString()));
        material.setType(0);    //0 图片  1 视频
        material.setIsCollection(0);
        material.setCreatedTime(LocalDateTime.now());
        material.setUrl(url);
        //执行增加操作
        wmMaterialMapper.insert(material);
        return Result.ok();
    }





}

